#include "stdafx.h"
#include "EE_FuelFlowModule.hpp"

#include "Namespaces.h"

void EE_FuelFlowModule::OnStart(StartState State) {

	Debug_LogF("Renaming Events. this->Resource = \"{0}\"", this->Resource);

	this->Actions["ToggleFuelFlow"]->guiName = String::Format("Toggle Resource ({0})", this->Resource);
	this->Actions["DisableFuelFlow"]->guiName = String::Format("Disable Resource ({0})", this->Resource);
	this->Actions["EnableFuelFlow"]->guiName = String::Format("Enable Resource ({0})", this->Resource);

}

void EE_FuelFlowModule::ToggleFuelFlow(KSPActionParam ^e) {

	if (e->type == KSPActionType::Activate) {

		this->EnableFuelFlow(e);

	} else {

		this->DisableFuelFlow(e);

	}

}

void EE_FuelFlowModule::DisableFuelFlow(KSPActionParam ^e) {

	auto Res = this->part->Resources[this->Resource];
	if (Res) {

		Res->flowState = false;

	}

}

void EE_FuelFlowModule::EnableFuelFlow(KSPActionParam ^e) {

	auto Res = this->part->Resources[this->Resource];
	if (Res) {

		Res->flowState = true;

	}

}